<?php
namespace app\admin\model;
use think\Model;
use think\Db;

class ActivityModel extends Model{

    /*
     * 育儿知识列表查询
     */
    public function selectAll($data)
    {
        $active_title = isset($data['active_title'])?$data['active_title']:"";
        if($active_title != ""){
            $res = Db::table('activity')
                ->where('is_del', 0)
                ->where('active_title','like',"%$active_title%")
                ->order('create_time desc')
                ->paginate(10);
            return $res;
        }else {
            $res = Db::table('activity')->where('is_del', 0)->order('create_time desc')->paginate(10);
            return $res;
        }
    }
    /*
     *添加
     */
    public function insertRow($data)
    {
        $row = Db::table('activity')->insert($data);
        return $row;
    }
    /*
     *查询一条
     */
    public function selectFind($id)
    {
        $res = Db::table('activity')->where(array('id'=>$id))->find();
        return $res;
    }
    /*
     *修改
     */
    public function saveFind($data){
        $row = Db::table('activity')->update($data);
        return $row;
    }

    /*
     *删除一条
     */
    public function deleteFind($id){
        $is_del['is_del'] = 1;
        $res = Db::table('activity')->where("id=$id")->update($is_del);
        return $res;
    }

    public function getSelectTime(){
        $time = Db::table('activity')->field('start_time')->order('create_time desc')->find();
        return $time;
    }


}